/*
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
H I D E  S P O N S O R  N A M E S
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
*/
--Update 
--	sp
--Set
--	[Name] = 'Sponsor ' + cast(sp.Id as varchar)
--	,ShortName = 'Sponsor ' + cast(sp.Id as varchar)
--	,Description = 'Sponsor ' + cast(sp.Id as varchar)
--From
--	AdmSponsor sp

/*
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
H I D E  P E R S O N  N A M E S
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
*/
Update 
	ap
Set
	LastName = 'Person ' + cast(ap.Id as varchar)
	,FirstName = 'First'
	,MiddleName = 'M'
From
	AdmPerson ap
/*
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
H I D E  A G R E E M E N T  N A M E S
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
*/
Update
	af
Set
	SponsorName = 'Sponsor '+cast(af.SponsorId as varchar)
	,Title = 'Project ' +  cast(af.Id as varchar)
	,ShortTitle = 'Project ' +  cast(af.Id as varchar)
	,PIFirstName = 'First'
	, PILastName = 'Person ' + cast(af.PrincipalInvestigatorId as varchar)
	,PIMiddleName = 'M'
	
From
	AgrAgreement_fct af


Update
	af
Set
	Title = 'Project ' +  cast(af.Id as varchar)
	,ShortTitle = 'Project ' +  cast(af.Id as varchar)	
From
	AgrAgreement af

/*
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
H I D E  R E S E A R C H  A D M I N I S T R A T O R S  N A M E S
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
*/
Update
	ra
Set
	 FirstName = 'First'
	,LastName = 'Person ' + cast(ra.Id as varchar)
	,phone = '111-1111'
	,fax = '111-1111'
	,email = 'first.person@myEmailAccount.org'
From
AdmResearchAdministrators ra

/*
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
H I D E  P A I D  P E R S O N N E L  F A C T  T A B L E  N A M E S
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
*/
Update
	sd
Set
	 FirstName = 'First'
	,LastName = 'Person ' + cast(ip.AdmPersonId as varchar)
From
PerSalaryDistributionSrc_Fct sd
inner join peremployee_job_Map ej on ej.id = sd.PerEmployeeJobMapId
inner join adminternalperson ip on ip.id = ej.AdmInternalPersonId

Update
	sd
Set
	 FirstName = 'First'
	,LastName = 'Person ' + cast(sd.AdmPersonId as varchar)
From
PerEmployeeJob_Fct sd

/*
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
H I D E  V E N D O R  A N D  R E Q U E S T O R  N A M E S
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
*/
drop index purVendor.IX_PurVendor_VendorName
Update
	v
Set
	 VendorName = 'Vendor ' + cast(v.Id as varchar)
	,ShortName = 'Vendor ' + cast(v.Id as varchar)
	,remarks = ''
From
purVendor v

create index IX_PurVendor_VendorName on purVendor (VendorName)

drop index purPOAPSummary_Fct.IX_PurPOAPSummary_Fct_RequestorName
drop index purPOAPSummary_Fct.IX_PurPOAPSummary_Fct_VendorName

Update
	ps
Set
	 VendorName = 'Vendor Name '+ cast(ps.Id as varchar)
	,RequestorName = 'Requestor Name '+ cast(ps.Id as varchar)
From
purPOAPSummary_Fct ps 

create index IX_PurPOAPSummary_Fct_VendorName on purPOAPSummary_Fct (VendorName)
create index IX_PurPOAPSummary_Fct_RequestorName on purPOAPSummary_Fct (RequestorName)

drop index PurPOAPFilterAndDetails_Fct.PurPOAPFilterAndDetails_Fct_RequestorName
drop index PurPOAPFilterAndDetails_Fct.PurPOAPFilterAndDetails_Fct_VendorName

Update
	pd
Set
	 VendorName = 'Vendor Name '+ cast(pd.Id as varchar)
	,RequestorName = 'Requestor Name '+ cast(pd.Id as varchar)
From
PurPOAPFilterAndDetails_Fct pd

create index PurPOAPFilterAndDetails_Fct_VendorName on PurPOAPFilterAndDetails_Fct (VendorName)
create index PurPOAPFilterAndDetails_Fct_RequestorName on PurPOAPFilterAndDetails_Fct (RequestorName)

drop index PurPOHeader_Src.IX_PurPOHeader_Src_RequestorName

Update
	ph
Set
	RequestorName = 'Requestor Name '+ cast(ph.Id as varchar)
From
PurPOHeader_Src ph

create index IX_PurPOHeader_Src_RequestorName on PurPOHeader_Src (RequestorName)



/*
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
H I D E  P R O T O C O L  T I T L E S
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
*/
Update 
	prot
SET
	Title = 'Title ' + cast (prot.Id as varchar), 
	ShortTitle = 'Title ' + cast (prot.Id as varchar)
From 
	Protocol prot

/*
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
H I D E  E M A I L
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
*/
Update 
	mail
SET
	EmailAddress = 'mail' + cast (mail.Id as varchar) + '@Partners.org'
From 
	AdmEmailAddress mail

/*
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
H I D E  P H O N E
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
*/
Update 
	phone
SET
	number = '555-1212'
From 
	AdmTelephoneNumber phone
 
/*
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
H I D E  S A L A R I E S
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
*/

begin transaction ken

update f set lastname = ap.lastname,firstname=ap.firstname from PerSalaryDistributionSrc_Fct f
inner join adminternalperson ip on ip.employeenumber = f.employeenumber
inner join admperson ap on ap.id = ip.id

update f set lastname = 'employee ' + f.employeenumber,firstname='first' from PerSalaryDistributionSrc_Fct f
left outer join adminternalperson ip on ip.employeenumber = f.employeenumber
left outer join admperson ap on ap.id = ip.id
where ap.lastname is null 

update f set lastname = ap.lastname,firstname=ap.firstname from PerEmployeeJob_Fct f
inner join adminternalperson ip on ip.employeenumber = f.employeenumber
inner join admperson ap on ap.id = ip.id

update f set lastname = 'employee ' + f.employeenumber,firstname='first' from PerEmployeeJob_Fct f
left outer join adminternalperson ip on ip.employeenumber = f.employeenumber
left outer join admperson ap on ap.id = ip.id
where ap.lastname is null 

commit transaction ken

/*
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
H I D E  P A T I E N T S
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
*/
update p set lastname = 'Patient ' + cast(p.id as varchar)
			,Firstname = 'First'
			,Middlename = 'M'
			,PatientMRN = cast(p.id as varchar)
from patient p

